package com.luli.controllor;

import com.luli.entity.UserData.QueryUserParam;
import com.luli.entity.response.ResponseMsg;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.KafkaAdminClient;
import org.apache.kafka.clients.admin.ListTopicsOptions;
import org.apache.kafka.clients.admin.ListTopicsResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.time.LocalDate;
import java.util.*;

import static com.luli.Utils.ResponseMsgUtil.getSuccessMsg;

/**
 * @Projectname: elasticsearch
 * @Filename: KafkaController
 * @Author: 陆离
 * @Data:2023/3/30 18:04:28
 */
@RestController
@Slf4j
@RequestMapping("/kafkaDemo")
@CrossOrigin
public class KafkaController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    /**
     * http://127.0.0.1:8086/LuLi/kafkaDemo/kafkaTest
     * @return
     * @throws IOException
     */
    @GetMapping("/kafkaTest")
    public ResponseMsg<?> kafkaTest() throws IOException {
        ListenableFuture<SendResult<String, String>> bigScreenDataDaos = kafkaTemplate.send("luliTest", "黑马程序员");
        return getSuccessMsg("200", "查询成功", bigScreenDataDaos);
    }

    public static void main(String[] args) {
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        if (StringUtils.isEmpty((CharSequence) objectObjectHashMap.get("name"))){
            System.out.println(1);
        }else System.out.println(2);
    }



}
